const crypto = require('crypto');
const fs = require('fs');

// 读取私钥
const privateKey = `-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCrWHyhQE2W2V3A
1sim5ruX3eWW4WeBGt5y0AhfIAchghVsLOojQ/gxqIQlQoMiq+jzxr8TfiPFrnGj
QDLOAiJur744mAN9JKaKktIejneiCWSQmO16qefvDKTsWIqDomi1NaGF++QV6x+x
AG1+b885qpaOFh21ZhdCoiB2mPstX9zMLUPtgCCYuFbrtQP5OnRtT1WQrr+1PsWV
z/gr9+GGf05vM1490iJCBifRulOnu7/V+3LBQnDgkl1zR4U+2Qt+xMhVb4bHHsud
YkVpm9pqhcFFQcq9LT+sYNVFp+aPoJX3qtbvET60fR8A3Hujw2fV4oNwgSlC7WjO
MbbggWc9AgMBAAECggEAdjjNdOzLHAPJ/h2zwAR+9p+xo1LOeXOyfAExZYDRqrr4
UPUEb2ScQJcG5jZoCGoYhupgN/DWebSMz5ih9SXf4AL9+kpYTeYVypLWyyJ9RJ26
d1IsuG+2iWdt+2xz1bMfD7h7Q9iyXLUn3pZu9cfrcNxUmKCFyv0vm1gFkg6nb3wN
kBEcxGCa+SJJP1xgQaByhh22I5/Rq10GPsfz1KdwWGiXiVEyz7GkItB4z0u/2WEl
tPJvXgfZxWR+bp860oLh+UOhiMb6Q8mjPuwcnIhWax3ko84WMILfisz29cYV+5ZN
2JkK8rJQVqGZZy5YxbJ0eeYQRrsOFG/B40S2vNaReQKBgQDcwn/575PeF/q1Qv8O
/Z5/O8svNXSOXsMpiwPrYmDd854i68hOG7xxrC1VxuvKCqcXqSO0kDDzuq0JM16A
uUzXtIxmXnFpfs/HThzpaj0wsnPyceSAfeXrwz+pY+1Ye6RCv8zofIObbYBDPodb
zgEMtHAV/vVJIi1+unwuR/UVIwKBgQDGsqUko/RZF/Zs1AjPGKjr82LQTk7fVJxS
3Pu//fCeMGvjLtq9hBrPB7TzmswYvYPmBTv+jG0UxCqJKqua8rx96LFF5JnvQByF
pfOZYwR4cdq2QbDdVB48kIwm2aZJ0GLbfAmG+uWTvKUD1n0eABx/LkuiWd+6fk/Z
e6w8x7ZIHwKBgGgi7AG3rRYQU7ibwPuOUe0NBLzhR3k9ZGy9YfzwbGdm20r31IZb
+RnaMYyMCIBHZCj6JZiwiBcBEU0MyWCJiKEcTzqfBHrSUitfQq4s6m6FT8KnTTX7
rbD4aph6ReT+di7ykTN+QQrZra6K2YlJ9R7MIy+NFKIKGFH2oEuosAjnAoGAZJNG
nk5TP8muVZXaQ6Gy14Qh71jD+a2lVxg+YgdTBW9zHNK5rBYzT7oR8QDY8Gj1W7go
jwdbq5hEA5xSsqLNoFnpaXx2IrFr/oZq0KhbOfA/ieOkd9O9XmC4YG3pCxHtCDY3
yFg1XtutF005lbbutb2kUTB227pWBrrgCv/4F3cCgYABwf9YIHVQF2L+lDrTEI9Q
LlBy/Ede8bm68TXT4KFQ0XMNms9mRKZ1cx5qFLhkP2aqPcMJuXhoK/Z3ckgnT4OS
jfo1uNGApgedheQIvwzfKSOXUA+vmKLWP7MsZ4/mm0cNrhIRMPngYzV3fmSbI3PL
AGWH01m22S7cdONC8rRjYA==
-----END PRIVATE KEY-----
`;

// 要签名的数据
const data = 'Hello, world!';

// 创建RSA算法对象
const sign = crypto.createSign('RSA-SHA256');

// 更新要签名的数据
sign.update(data);

// 对数据进行签名
const signature = sign.sign(privateKey, 'hex');

console.log('Signature:', signature);

